/*
 * Copyright (C) 2007 Christian Laireiter <liree@web.de>
 * 
 * This program is free software; you can redistribute it and/or modify it under the terms 
 * of the GNU General Public License as published by the Free Software Foundation; either 
 * version 2 of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, 
 * but WITHOUT ANY WARRANTY; without even the implied 
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
 * See the GNU General Public License for more details.
 *  
 *  You should have received a copy of the GNU General Public License along with 
 *  this program; if not, write to the Free Software Foundation, 
 *  Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
 */
package mo.network;

import mo.network.client.listeners.IReceiver;
import mo.network.client.listeners.ISender;
import mo.network.server.data.Packet;

/**
 * This interface declares common networking methods for both, client and
 * server.<br>
 * 
 * @author Christian Laireiter
 */
public interface NetworkPeer {

    /**
     * Adds a new listener for incoming packets . A listener cannot be
     * registered twice!
     * 
     * @param receiver
     *            the listener to add to the list of receive listeners
     */
    void addReceiveListener(final IReceiver receiver);

    /**
     * Adds a new listener for outgoing packets. A listener cannot be registered
     * twice!
     * 
     * @param sender
     *            the listener to add to the list of receive listeners
     */
    void addSendListener(final ISender sender);

    /**
     * This method enqueues the given packet to be send through the network
     * interface.<br>
     * 
     * @param newPacket
     *            saves the packet to send
     */
    void queueUpload(final Packet newPacket);

    /**
     * Removes a receive listener from the list of listeners.
     * 
     * @param receiver
     *            the receive listener to be removed from the list
     */
    void removeReceiveListener(final IReceiver receiver);

    /**
     * Removes a send listener from the list of listeners.
     * 
     * @param sender
     *            the send listener to be removed from the list
     */
    void removeSendListener(final ISender sender);

}
